{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "[this doc on github](https://github.com/dotnet/interactive/tree/main/samples/notebooks/fsharp/Docs)\n",
    "\n",
    "# Importing Packages, Libraries, and Scripts"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can load packages into a .NET notebook from NuGet using the following syntax:\n",
    "\n",
    "```fsharp\n",
    "#r \"nuget:<package name>[,<version=package version>]\"\n",
    "```\n",
    "\n",
    "You can specify alternative sources using `#i`:\n",
    "\n",
    "```fsharp\n",
    "#i \"nuget:<nuget-source>\"\n",
    "```\n",
    "\n",
    "\n",
    "If you don't provide an explicit package version, the latest available non-preview version will be loaded.\n",
    "\n",
    "Here's an example:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "fsharp"
    }
   },
   "outputs": [],
   "source": [
    "#r \"nuget:FSharp.Data\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now that the package is loaded, we can add some `open` statements and write some code."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "fsharp"
    }
   },
   "outputs": [],
   "source": [
    "open FSharp.Data\n",
    "\n",
    "[<Literal>]\n",
    "let url = \"https://en.wikipedia.org/wiki/2017_Formula_One_World_Championship\"\n",
    "\n",
    "type F1_2017 = HtmlProvider<url>\n",
    "    \n",
    "let f1Calendar = F1_2017.Load(url).Tables.``Season calendar``\n",
    "\n",
    "f1Calendar.Rows\n",
    "|> Seq.map (fun x -> x.Circuit, x.Date)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If you want to load an assembly that's already on disk, you can do so using this syntax:\n",
    "\n",
    "```fsharp\n",
    "#r \"<path to .dll>\"\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can load an F# script (typically a `.fsx` file) into the notebook using this syntax:\n",
    "\n",
    "```fsharp\n",
    "#load \"<path to .fsx file>\"\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "fsharp"
    }
   },
   "outputs": [],
   "source": [
    "// Example:\n",
    "#load \"some-fsharp-script-file.fsx\""
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".NET (F#)",
   "language": "F#",
   "name": ".net-fsharp"
  },
  "language_info": {
   "file_extension": ".fs",
   "mimetype": "text/x-fsharp",
   "name": "C#",
   "pygments_lexer": "fsharp",
   "version": "4.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
